"""计数器控件"""
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import *

class QSpinBoxDemo(QWidget):
    def __init__(self):
        super(QSpinBoxDemo, self).__init__()
        self.iniUI()


    def iniUI(self):
        self.setWindowTitle('QSpinBox计数器控件')
        self.resize(300, 100)

        layout = QVBoxLayout()
        self.label = QLabel('当前值')
        self.label.setFont(QFont('SimHei', 12))
        self.label.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.label)

        self.sb=QSpinBox()
        self.sb.setValue(88)
        self.sb.setMinimum(-1)
        self.sb.setMaximum(9999999)
        layout.addWidget(self.sb)
        self.sb.valueChanged.connect(self.valueChange)

        self.setLayout(layout)

    def valueChange(self):
        self.label.setText('当前值：'+str(self.sb.value()))


if __name__ == '__main__':
    app = QApplication(sys.argv)
    main = QSpinBoxDemo()
    main.show()
    sys.exit(app.exec_())


